package net.lzzy.gitdemo;

import java.io.*;

public class Java_demo2 {
    public static void main(String[] args) throws IOException {
        try ( // Create an output stream for file temp.dat
//              为文件临时创建输出流.dat
              DataOutputStream output =
                      new DataOutputStream(new FileOutputStream("temp.dat"));
        ){
            // Write student test score to the file
//            将学生考试成绩写入文件
            output.writeUTF("John");
            output.writeDouble(85.5);
            output.writeUTF("jim");
            output.writeDouble(185.5);
            output.writeUTF("George");
            output.writeDouble(105.25);
        }
    try ( //Create an input stream for file tmep.dat
          //为文件 tmep 创建输入流.dat
        DataInputStream input =
                new DataInputStream(new FileInputStream("temp.dat"));
    ){
        // Read student test scores from the file
//        从文件中读取学生考试成绩
        System.out.println(input.readUTF()+" "+input.readDouble());
        System.out.println(input.readUTF()+" "+input.readDouble());
        System.out.println(input.readUTF()+" "+input.readDouble());
    }
    }
}
